package com.feicheng.lanniao.controller.pc;

import java.time.LocalDateTime;

import com.feicheng.lanniao.anno.StaticSelectCountOfHouseSellInfo;
import org.aspectj.weaver.patterns.ThisOrTargetAnnotationPointcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.feicheng.lanniao.entity.HouseSell;
import com.feicheng.lanniao.entity.HouseSellClientVo;

import com.feicheng.lanniao.result.ResultInfo;
import com.feicheng.lanniao.service.IHouseSellClientVoService;
import com.feicheng.lanniao.service.IHouseSellService;

/**
 * <p>
 * VIEW 前端控制器
 * </p>
 *
 * @author feichengTech
 * @since 2021-09-07
 */
@RestController
@RequestMapping("/lanniao-user/house-sell-client-vo")
public class HouseSellClientPcController {

	@Autowired
	private IHouseSellClientVoService iHouseSellClientVoService;

	/**
	 * 卖房列表查询
	 * @param des 房子描述
	 * @param provienceId 省
	 * @param cityId 市
	 * @param reignId 区
	 * @param clientId 用户id
	 * @param sellId 卖房id
	 * @param typeName 产权表中的产权名字
	 * @param houseAreaId 面积区间表id
	 * @param sellPriceId 价格区间表id
	 * @param currentPage 当前页
	 * @param pageSize 每页多少条
	 * @return 卖房列表集合
	 */
	@GetMapping("/page")
	public ResultInfo getList(
			String des,Integer provienceId,
			Integer cityId, Integer reignId,
			Integer clientId, Integer sellId,
			String typeName, Integer houseAreaId, Integer sellPriceId,
			String tel,
			String wxNumber,
			String louceng,
			String xiaoqu,
			String pianqu,
			String chaoxiang,
			String zhuangxiu,
			Integer dianti,
			String niandai,
			Integer roomCount,
			@RequestParam(defaultValue = "1") int currentPage, @RequestParam(defaultValue = "10") Integer pageSize,String sort,Boolean dec) {
		return iHouseSellClientVoService.getList(des, provienceId, cityId,
				reignId, clientId, sellId, typeName, houseAreaId, sellPriceId, tel,wxNumber,
				louceng,xiaoqu,pianqu,chaoxiang,zhuangxiu,dianti,niandai,roomCount,currentPage, pageSize,sort, dec);
	}

	/**
	 * 查询卖房详情
	 *
	 * @param sellId 卖房id
	 * @return 返回卖房详情
	 */
	//@StaticSelectCountOfHouseSellInfo
	@GetMapping("/info")
	public ResultInfo info(Integer sellId) {
		return ResultInfo.success(iHouseSellClientVoService.getById(sellId));
	}

	@Autowired
	private IHouseSellService iHouseSellService;


	/**
	 * 新增1个卖房信息
	 * @param totalPrice	总价
	 * @param propertType	产权类型
	 * @param propertYear	产权年限
	 * @param clientId		用户ID
	 * @param roomCount		户型
	 * @param area			面积
	 * @param provienceId	省ID
	 * @param cityId		市ID
	 * @param reignId		区ID
	 * @param imgUrl		图片地址
	 * @param tel			发布电话
	 * @param wxNumber		微信号
	 * @param louceng		楼层
	 * @param xiaoqu		小区
	 * @param pianqu		片区
	 * @param chaoxiang		朝向
	 * @param zhuangxiu		装修
	 * @param dianti		电梯	
	 * @param niandai		年代
	 * @return 布尔值 true-成功 false-失败
	 */
	@PostMapping("/info")
	public ResultInfo addHouseSell(Integer totalPrice, Integer propertType, String propertYear,
			Integer clientId, 
			Integer roomCount, Integer area, Integer provienceId, Integer cityId, Integer reignId, String imgUrl,
			String tel,
			String wxNumber,
			String louceng,
			String xiaoqu,
			String pianqu,
			String chaoxiang,
			String zhuangxiu,
			Integer dianti,
			String niandai
								   // 13-3
	) {
		return iHouseSellService.addHouseSell( totalPrice, propertType, propertYear, clientId, 
				 roomCount, area, provienceId, cityId, reignId, imgUrl, 
				tel,
				wxNumber,
				louceng,
				xiaoqu,
				pianqu,
				chaoxiang,
				zhuangxiu,
				dianti,
				niandai
		);
	}


	/**
	 * 修改1个卖房信息
	* @param sellId 		卖方Id
	 * @param totalPrice	总价
	 * @param propertType	产权类型
	 * @param propertYear	产权年限
	 * @param roomCount		户型
	 * @param area			面积
	 * @param provienceId	省
	 * @param cityId		市
	 * @param reignId		区
	 * @param imgUrl		图片
	 * @param tel			发布电话
	 * @param wxNumber		发布微信
	 * @param louceng		楼层
	 * @param xiaoqu		小区
	 * @param pianqu		片区
	 * @param chaoxiang		朝向
	 * @param zhuangxiu		装修
	 * @param dianti		电梯
	 * @param niandai		年代
	 * @return 				布尔值 true-成功 false-失败
	 */
	@PutMapping("/info")
	public ResultInfo editHouseSell(Integer sellId,  Integer totalPrice, Integer propertType,
			 String propertYear,  Integer roomCount, Integer area, Integer provienceId, Integer cityId,
			 Integer reignId, String imgUrl, 
			 String tel,
			 String wxNumber,
			 String louceng,
			 String xiaoqu,
			 String pianqu,
			 String chaoxiang,
			 String zhuangxiu,
			 Integer dianti,
			 String niandai
	) {
		return ResultInfo.success(iHouseSellService.editHouseSell(sellId,totalPrice, propertType, propertYear, 
				 roomCount, area, provienceId, cityId, reignId, imgUrl, 
				tel,
				wxNumber,
				louceng,
				xiaoqu,
				pianqu,
				chaoxiang,
				zhuangxiu,
				dianti,
				niandai
		));
	}

	/**
	 * 删除1个卖房信息
	 *
	 * @param houseSell 卖房对象
	 * @return 布尔值 true-成功 false-失败
	 */
	@DeleteMapping("/info")
	public ResultInfo removeHouseSell(HouseSell houseSell) {

		return ResultInfo.success(iHouseSellService.remove(houseSell));
	}

}
